import api from '@/common/request.js'
/**
 * API单独管理
 */

/*
示例

this.$httpApis.login({
	userName:userName,
	passWord:passWord
})
.then(res=>{
	this.$u.toast('登陆成功');
	
	uni.redirectTo({
		url: '/pages/index/index'
	});
	
})
.catch(err=>{
	
})

*/



// 登陆接口
const login = (options, errorlog = true, mask = true) => {
	return api.requests({
		url:'/login',
		method: 'post',
		data:options
	})
}

// 增加
function addUser(options, errorlog = true, mask = true){
	return api.requests({
		url:'/user/add',
		method: 'POST',
		data:options
	})
}

// 删除
function delUserById(options, errorlog = true, mask = true){
	return api.requests({
		url:'/user/del?id=' + options.id,
		method: 'get',
		data:options
	})
}

// 修改
function updateUserById(options, errorlog = true, mask = true){
	return api.requests({
		url: `/user/update/${options.id}`,
		method: 'post',
		data:options
	})
}

// 查询
function getInfoById(options, errorlog = true, mask = true){
	return api.requests({
		url: `/user/${options.id}`,
		method: 'get',
		data:options
	})
}

// 获取用户列表
function getUserList(options, errorlog = true, mask = true){
	return api.requests({
		url:'/users',
		method: 'get',
		data:options
	})
}


export default {
	login,
	addUser,
	delUserById,
	updateUserById,
	getInfoById,
	getUserList
}
